|
|
|
|
|
|
|
|
Some controls, such as the CheckBox and ComboBox, use the Click event instead of the Change event to handle the change notification.  |
|
|
|
|
|
|
|
|
|
|
All you have to do is set the Changed property of the Property Page object to True, which tells Visual Basic to enable the Apply button. The code for the Change and Click events of the CalcGeneral page is shown in Listing 15.6. |
|
|
|
|
|
|
|
|
Listing 15.6 CALC.ZIPActivating the Apply Button with the Changed Property |
|
|
|
|
|
|
|
|
Private Sub cmbOperation_Click()
Changed = True
End Sub
Private Sub txtButtonCaption_Change()
Changed = True
End Sub
Private Sub txtCaption_Change()
Changed = True
End Sub |
|
|
|
|
|
|
|
|
Implementing the ApplyChanges Event Procedure |
|
|
|
|
|
|
|
|
The ApplyChanges event is the opposite of the SelectionChanged event. Whereas the SelectionChanged event procedure loads information into the Property Page, the ApplyChanges event procedure saves new values back to the control. This event fires when the developer closes the Property Page or clicks the Apply button. For the Calculator control, you simply need to take the properties from the Property Page's controls and assign them to the custom control, as shown in Listing 15.7. |
|
|
|
|
|
|
|
|
Listing 15.7 CALC.ZIPThe ApplyChanges Event Procedure |
|
|
|
|
|
|
|
|
Private Sub PropertyPage_ApplyChanges()
SelectedControls(0).Caption = txtCaption
SelectedControls(0).ButtonCaption = txtButtonCaption
SelectedControls(0).Operation = cmbOperation.ListIndex
End Sub |
|
|
|
|
|
|
|
|
Connecting the Property Page to the Control |
|
|
|
|
|
|
|
|
The Property Page you have been building is now complete. To use the CalcGeneral Property Page with your control, however, you must first connect the Property Page to the control. (Remember, the Property Page is a separate object or file that can be used with several controls.) To perform this final task, follow these steps: |
|
|
|
|
|
|
|
|
1. Display the user control designer window for the Calculator control. |
|
|
|
|
|
|
|
|
2. In the control's Properties window, double-click the PropertyPages property. The Connect Property Pages dialog box appears. |
|
|
|
|
|